import { request } from '../request';


export function userLogin(data: any) {
    return request.post<string>('/nurse_user/nurseUser/login', data, {
        useErrMsg: true
    });
}

export function queryByOpenId(data: any) {
    return request.get<NurseUser.nurseUser>('/nurse_user/nurseUser/queryByOpenId', data, {
        useErrMsg: true
    });
}


export function edit(data: any) {
    return request.put('/nurse_user/nurseUser/editByWeChat', data, {
        useErrMsg: true
    });
}

export function deleteAddr(id: string) {
    return request.delete(`/nurse_user/nurseUser/deleteNurseUserAddr?id=${id}`, {}, {
        useErrMsg: true
    });
}


export function deleteHomeAddr(id: string) {
    return request.delete(`/nurse_home_addr/nurseHomeAddr/delete?id=${id}`, {id}, {
        useErrMsg: true
    });
}


export function addHomeAddr(obj: any) {
    return request.post(`/nurse_home_addr/nurseHomeAddr/add`, obj, {
        useErrMsg: true
    });
}

export function editHomeAddr(obj: any) {
    return request.put(`/nurse_home_addr/nurseHomeAddr/edit`, obj, {
        useErrMsg: true
    });
}

export function getHomeAddr(id: string) {
    return request.get(`/nurse_home_addr/nurseHomeAddr/queryById?id=${id}`, {}, {
        useErrMsg: true
    });
}

export function listHomeAddr(userId: string) {
    return request.get(`/nurse_home_addr/nurseHomeAddr/list?userId=${userId}`, {}, {
        useErrMsg: true
    });
}

// 设置默认居家护理地址
export function setDefaultHomeAddr(addId: string, userId: string) {
    return request.post(`/nurse_home_addr/nurseHomeAddr/setDefaultAdd`, {
        addId, userId
    }, {
        useErrMsg: true,
        contentType: 'application/x-www-form-urlencoded'
    });
}




export function add(data: any) {
    return request.post<NurseUser.nurseUser>('/nurse_user/nurseUser/add', data, {
        useErrMsg: true
    });
}



export function refreshSpecial(userId: string) {
    return request.get<any>(`/nurse_user/nurseUser/refreshSpecial?userId=${userId}`, {}, {
        useErrMsg: true
    });
}


export function getSpecialList({ pageNo, pageSize, userId, isvalid }: any) {
    return request.get<any>(`/nurse_user/nurseUser/getSpecialList?pageNo=${pageNo}&pageSize=${pageSize}&userId=${userId}&isvalid=${isvalid}`, {}, {
        useErrMsg: true
    });
}


export function editDefaultHospital({ userId, defaultHospital, defaultHospitalName }: any) {
    return request.get<any>(`/nurse_user/nurseUser/editDefaultHospital?userId=${userId}&defaultHospital=${defaultHospital}&defaultHospitalName=${defaultHospitalName}`, {}, {
        useErrMsg: true
    });
}

export function getVisibleByHospital(id: string) {
    return request.get<any>(`/page_visible/pageVisible/list?hospitalId=${id}`, {}, {
        useErrMsg: true
    });
}
